package yuchen.ballanimation;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;



/**
 * Created by yuchen on 5/19/16.
 */
public class Ball extends View {


    public Ball(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public Ball(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override

    protected void onDraw(Canvas canvas) {

        super.onDraw(canvas);

        //创建画笔
        Paint paint=new Paint();
        paint.setAntiAlias(true);
        paint.setColor(Color.RED);
        //绘制一个小圆
        //Log.d("=/=/=/=/=/",canvas.getWidth() + "," + canvas.getHeight());
        canvas.drawCircle(this.getWidth()/2, this.getHeight()/2, this.getWidth()/2, paint);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
}
